package TwoPoint;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dx
 * @version 1.0
 * @date 2022/5/23 9:49
 * @description:  力扣11 盛水最多的容器
 */
public class MaxArea {
}


class MaxArea_Solution{
    //暴力破解
    public int maxArea1(int []height){
        int len = height.length;
        int max = -1;
        for(int i = 0;i<len-1;i++){
            for(int j=i+1;j<len;j++){
                int val = Math.min(height[i],height[j]);
                max = Math.max(max,(j-i)*val);
            }
        }
        return max;
    }
    //双指针法
    public int maxArea2(int []height){
        int len = height.length;
        int ans = -1;
        int i = 0;
        int j = len - 1;
        while(i<j){
            int tem = (j - i)*Math.min(height[i],height[j]);
            ans = Math.max(tem,ans);
            if(height[i] < height[j]){
                i++;
            }else {
                j--;
            }
        }
        return ans;
    }
}
